} datum_mapping_t;
/* will be continued (when requested) */
-datum_mapping_t gt_mps_datum_names[] =
+static datum_mapping_t gt_mps_datum_names[] =
{
{ "Alaska-NAD27", "NAD27 Alaska" },
{ "Bahamas NAD27", "NAD27 Bahamas" },
{ NULL, NULL }
};
+typedef struct garmin_color_s {
+ char *name;
+ gbint32 rgb;
+} garmin_color_t;
+
+static garmin_color_t gt_colors[] =
+{
+ { "Unknown", unknown_color },
+ { "Black", 0x000000 },
+ { "DarkRed", 0x00008B },
+ { "DarkGreen", 0x006400 },
+ { "DarkYellow", 0x008B8B },
+ { "DarkBlue", 0x8B0000 },
+ { "DarkMagenta", 0x8B008B },
+ { "DarkCyan", 0x8B8B00 },
+ { "LightGray", 0xD3D3D3 },
+ { "DarkGray", 0xA9A9A9 },
+ { "Red", 0x0000FF },
+ { "Green", 0x008000 },
+ { "Yellow", 0x00FFFF },
+ { "Blue", 0xFF0000 },
+ { "Magenta", 0xFF00FF },
+ { "Cyan", 0xFFFF00 },
+ { "White", 0xFFFFFF },
+ { "Transparent", unknown_color }, /* Currently not handled */
+ { NULL }
+};
+
+#define GT_COLORS_CT ((sizeof(gt_colors) / sizeof(gt_colors[0])) - 1)
+
unsigned char
gt_switch_display_mode_value(const unsigned char display_mode, const int protoid, const char device)
{
return result;
}
+gbuint32
+gt_color_value(const int garmin_index)
+{
+ if ((garmin_index >= 0) && (garmin_index < GT_COLORS_CT))
+ return gt_colors[garmin_index].rgb;
+ else
+ return unknown_color; /* -1 */
+}
+
+gbuint32
+gt_color_value_by_name(const char *name)
+{
+ int i;
+
+ for (i = 0; i < GT_COLORS_CT; i++)
+ if (case_ignore_strcmp(gt_colors[i].name, name) == 0)
+ return gt_colors[i].rgb;
+
+ return gt_colors[0].rgb;
+}
+
+int
+gt_color_index_by_name(const char *name)
+{
+ int i;
+
+ for (i = 0; i < GT_COLORS_CT; i++)
+ if (case_ignore_strcmp(name, gt_colors[i].name) == 0) return i;
+
+ return 0; /* unknown */
+}
+
+int
+gt_color_index_by_rgb(const int rgb)
+{
+ int i;
+
+ for (i = 0; i < GT_COLORS_CT; i++)
+ if (rgb == gt_colors[i].rgb) return i;
+
+ return 0; /* unknown */
+}
+
+const char *
+gt_color_name(const int garmin_index)
+{
+ if ((garmin_index >= 0) && (garmin_index < GT_COLORS_CT))
+ return gt_colors[garmin_index].name;
+ else
+ return gt_colors[0].name;
+}
+
#if MAKE_TABLE
/*
char *gt_get_mps_grid_longname(const grid_type grid, const char *module);
int gt_lookup_datum_index(const char *datum_str, const char *module);
char *gt_get_mps_datum_name(const int datum_index);
+gbuint32 gt_color_value(const int garmin_index);
+gbuint32 gt_color_value_by_name(const char *name);
+int gt_color_index_by_name(const char *name);
+int gt_color_index_by_rgb(const int rgb);
+const char *gt_color_name(const int garmin_index);
#endif
2007/07/07: Better support for new fields since V3 (postal code/street address/instruction)
2008/01/09: Fix handling of option category (cat)
2008/04/27: Add zero to checklist of "unknown bytes"
+ 2008/08/17: Add concept of route/track line colors
*/
#include <stdio.h>
/*******************************************************************************/
-/* static char gdb_release[] = "$Revision: 1.65 $"; */
-static char gdb_release_date[] = "$Date: 2008/05/04 23:09:08 $";
+/* static char gdb_release[] = "$Revision: 1.66 $"; */
+static char gdb_release_date[] = "$Date: 2008/08/17 21:07:43 $";
static gbfile *fin, *fout;
static int gdb_ver, gdb_category, gdb_via, gdb_roadbook;
}
GMSD_SET(display, display);
- FREAD_i32; /* color/colour !not implemented! */
+ FREAD_i32; /* color !not implemented! */
icon = FREAD_i32;
GMSD_SET(icon, icon); /* icon */
FREAD_STR(buf); /* city */
int points, warnings, links, i;
char buf[128];
bounds bounds;
-
+ int color_idx;
+
rte_ct++;
warnings = 0;
else {
rte->rte_url = gdb_fread_strlist();
- FREAD(buf, 4); /* ?????????????????????????????????? */
+ color_idx = FREAD_i32;
+ rte->line_color.bbggrr = gt_color_value(color_idx);
FREAD(buf, 1); /* ?????????????????????????????????? */
rte->rte_desc = FREAD_CSTR;
route_head *res;
int points, index;
char dummy;
-
+ int color_idx;
+
trk_ct++;
res = route_head_alloc();
// res->rte_num = trk_ct;
FREAD(&dummy, 1); /* display - 1 byte */
- FREAD_i32; /* color - 1 dword */
-
+ color_idx = FREAD_i32; /* color - 1 dword */
+ res->line_color.bbggrr = gt_color_value(color_idx);
+
points = FREAD_i32;
for (index = 0; index < points; index++)
FWRITE_CSTR(wpt->description);
FWRITE_DBL(WAYPT_GET(wpt, proximity, unknown_alt), unknown_alt); /* proximity */
FWRITE_i32(display); /* display */
- FWRITE_i32(0); /* color (colour) */
+ FWRITE_i32(0); /* color */
FWRITE_i32(icon); /* icon */
FWRITE_CSTR(GMSD_GET(city, "")); /* city */
FWRITE_CSTR(GMSD_GET(state, "")); /* state */
}
else /* if (gdb_ver >= GDB_VER_3) */ {
FWRITE_CSTR_LIST(rte->rte_url);
- FWRITE_i32(0x0E); /* color ??? */
+ /* "Magenta" (14) is MapSource default */
+ FWRITE_i32( (rte->line_color.bbggrr < 0) ? 14 : gt_color_index_by_rgb(rte->line_color.bbggrr) );
FWRITE_C(0);
FWRITE_CSTR(rte->rte_desc);
}
FWRITE_CSTR(trk_name);
FWRITE_C(0);
- FWRITE_i32(0);
+ /* "Unknown" (0) is MapSource default */
+ FWRITE_i32(gt_color_index_by_rgb(trk->line_color.bbggrr));
FWRITE_i32(points); /* total number of waypoints in waypoint list */